#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
using namespace std;
const int N = 1e5 + 10;
int tree[N];
int num[N];
int n1, n;
int lowbit(int x)
{
	return x & -x;
}
void add(int x, int v)
{	
	for (int i = x; i <= n; i+=lowbit(i)) {
		tree[i] += v;
	}
}

int query(int x)
{
	int ans = 0;
	for (int i = x; i; i -= lowbit(i)) {
		ans += tree[i];
	}
	return ans;
}
int main()
{
	vector<int>backup;
	cin >> n1;
	for (int i = 0; i < n1; i++) {
		cin >> num[i];
		backup.push_back(num[i]);
	}
	sort(backup.begin(), backup.end());
	backup.erase(unique(backup.begin(), backup.end()), backup.end());
	unordered_map<int, int>mp;
	n = backup.size();	
	for (int i = 0; i < n; i++) {
		mp[backup[i]] = i + 1;
	}
	int ans = 0;
	for (int i = 0; i < n1; i++) {
		int idx =  mp[num[i]];
		ans += max(0, i - query(idx));
		add(idx, 1);
	}
	cout << ans << endl;
	return 0;
}